package com.meiyou.service.impl;

import java.util.List;
import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.meiyou.mapper.MeiyouGuideMapper;
import com.meiyou.mapper.MeiyougbaskMapper;
import com.meiyou.pojo.EasyUIDataGrid;
import com.meiyou.pojo.GuideDetails;
import com.meiyou.pojo.MeiyouGuide;
import com.meiyou.pojo.MeiyouGuideExample;
import com.meiyou.pojo.Meiyougbask;
import com.meiyou.pojo.vo.GuideVo;
import com.meiyou.service.GuideService;

@Service
public class GuideServiceImpl implements GuideService {
	@Resource
	private MeiyouGuideMapper meiyouGuideMapper;
	@Resource
	private MeiyougbaskMapper meiyougbaskMapper;

	public int insGuide(MeiyouGuide meiyouGuide) {
		return meiyouGuideMapper.insertSelective(meiyouGuide);
	}

	
	public List<GuideVo> selMyGuide(String uCount) {
		return meiyouGuideMapper.selMyGuide(uCount);
	}

	
	public List<MeiyouGuide> selGuide(MeiyouGuide meiyouGuide) {
		MeiyouGuideExample example = new MeiyouGuideExample();
		return meiyouGuideMapper.selectByExampleWithBLOBs(example);
	}

	
	public int delGuide(int gId) {
		MeiyouGuideExample example = new MeiyouGuideExample();
		example.createCriteria().andGIdEqualTo(gId);
		return meiyouGuideMapper.deleteByPrimaryKey(gId);
	}

	
	public List<MeiyouGuide> showGuide(MeiyouGuide meiyouGuide) {
		return meiyouGuideMapper.selectGuide(meiyouGuide);
	}

	
	public EasyUIDataGrid selgUCount(String gUCount, int rows, int page) {
		PageHelper.startPage(page, rows);
		List<MeiyouGuide> list = meiyouGuideMapper.selectAll(gUCount);
		PageInfo<MeiyouGuide> pi = new PageInfo<MeiyouGuide>(list);
		EasyUIDataGrid dataGrid =new EasyUIDataGrid();
		dataGrid.setRows(pi.getList());
		dataGrid.setTotal(pi.getTotal());
		return dataGrid;
	}

	
	public MeiyouGuide selGuideById(int gId) {
		return meiyouGuideMapper.selGuideById(gId);
	}

	
	public List<GuideVo> selAllGuide(String gUCount) {
		return meiyouGuideMapper.selAllGuide(gUCount);
	}

	
	public List<GuideVo> selAllGuideTerm(String gUCount,String uSex) {
		return meiyouGuideMapper.selAllGuideTerm(gUCount,uSex);
	}

	
	public GuideDetails selGuideDetails(int gId) {
		return meiyouGuideMapper.selGuideDetails(gId);
	}

	
	public int selMeijin(int gId) {
		return meiyouGuideMapper.selMeijin(gId);
	}

	
	public int insGbask(Meiyougbask meiyougbask) {
		return meiyougbaskMapper.insert(meiyougbask);
	}

	
	public List<GuideVo> selMyGuideApply(String uCount) {
		return meiyouGuideMapper.selMyGuideApply(uCount);
	}

	
	public int selGuideAssess(int gId) {
		return meiyouGuideMapper.selGuideAssess(gId);
	}

	
	public int updGuideAssess(int gAssess, int gId) {
		return meiyouGuideMapper.updAssess(gAssess, gId);
	}

}
